<template>
    <div class="login-container">
      <el-card class="login-box">
        <h2 class="title">用户登录</h2>
        <el-form :model="form" label-width="80px">
          <!-- 账户名输入 -->
          <el-form-item label="账户名">
            <el-input 
              v-model="form.username" 
              placeholder="请输入账户名"
              clearable
            />
          </el-form-item>
  
          <!-- 密码输入 -->
          <el-form-item label="密码">
            <el-input
              v-model="form.password"
              type="password"
              placeholder="请输入密码"
              show-password
            />
          </el-form-item>
  
          <!-- 登录按钮 -->
          <el-form-item>
            <el-button 
              type="primary" 
              @click="handleLogin"
              class="login-btn"
            >
              立即登录
            </el-button>
          </el-form-item>
  
          <!-- 辅助功能 -->
          <div class="footer-links">
            <el-link type="info" @click="goForget">忘记密码?</el-link>
            <el-link type="primary" @click="goRegister">去注册</el-link>
          </div>
        </el-form>
      </el-card>
    </div>
  </template>
  
  <script setup>
  import { reactive } from 'vue'
  import { useRouter } from 'vue-router'
  import { ElMessage } from 'element-plus'
  
  const router = useRouter()
  const form = reactive({
    username: '',
    password: ''
  })
  
  // 登录处理
  const handleLogin = () => {
    if (!form.username || !form.password) {
      ElMessage.warning('请填写完整登录信息')
      return
    }
    // 这里添加实际登录逻辑
    console.log('登录信息:', form)
    ElMessage.success('登录成功')
  }
  
  // 跳转注册页
  const goRegister = () => {
    router.push('/register')
  }
  
  // 跳转忘记密码页
  const goForget = () => {
    router.push('/forget-password')
  }
  </script>
  
  <style scoped>
  .login-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f0f2f5;
  }
  
  .login-box {
    width: 400px;
    padding: 20px;
  }
  
  .title {
    text-align: center;
    margin-bottom: 30px;
    color: #409EFF;
  }
  
  .login-btn {
    width: 100%;
    margin-top: 10px;
  }
  
  .footer-links {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
  }
  </style>
  